// https://blog.csdn.net/baidu_41601048/article/details/127495307 (摘用  router v6 好使)
// 路由鉴权
import React from 'react'
import { useLocation, Navigate } from 'react-router-dom'

function Author({ children }) {
  const token = sessionStorage.getItem('token')
  const location = useLocation()
  // console.log(location, 'location')
  if (token) {
    return children
  } else {
    return <Navigate to="/login" replace></Navigate>
  }
}
export default Author
